package com.atguigu.yygh.hosp.controller;

import com.atguigu.yygh.common.result.Result;
import com.atguigu.yygh.hosp.service.ScheduleService;
import com.atguigu.yygh.model.hosp.Schedule;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

/**
 * @author ybl
 * @version 1.9
 * @date 2021/5/19 10:32
 */
@Api(tags = "排班操作")
@RestController
@RequestMapping("/admin/hosp/schedule")
public class ScheduleController {

  @Autowired
  private ScheduleService scheduleService;

  //根据医院编号 、科室编号和工作日期，查询排班详细信息
  @ApiOperation(value = "查询排班详细信息")
  @GetMapping("/getScheduleDetail/{hoscode}/{depcode}/{workDate}")
  public Result getByHoscodeAndDepcodeAndWorkDate(
      @PathVariable String hoscode,
      @PathVariable String depcode,
      @PathVariable String workDate
      ){
    List<Schedule> list = scheduleService.getDetailSchedule(hoscode,depcode,workDate);
    return Result.ok(list);
  }

  // 根据hoscode和depcode查询schedule
  @ApiOperation(value = "根据hoscode和depcode查询schedule")
  @GetMapping("findByHoscodeAndDepcode/{page}/{limit}/{hoscode}/{depcode}")
  public Result getByHoscodeAndDepcode(@PathVariable Long page,
                                        @PathVariable Long limit,
                                        @PathVariable String hoscode,
                                        @PathVariable String depcode){
    Map<String,Object> scheduleList = scheduleService.findByHoscodeAndDepcode(page,limit,hoscode,depcode);
    return Result.ok(scheduleList);
  }

}
